<template>
	<view class="content">
		<page-header :title="title" :show="isShow"></page-header>
		<view class="container">
			<scroll-view scroll-y="true" >
				<view class="index-search">
					<text class="iconfont icon-fangdajing"></text>
					<input type="text" value=""  placeholder="搜索歌曲" />
				</view>
				
				<view class="index-list" v-for="item in topList" :key="item.ToplistType">
					<view class="index-list-item">
						<view class="index-list-img" @tap="toList(item.id)">
							<image :src="item.coverImgUrl" mode=""></image>
							<text>{{item.updateFrequency}}</text>
						</view>
						<view class="index-list-text">
							<view v-for="(song,index) in item.tracks">{{index+1}}.{{song.first}} - {{song.second}}</view>
						</view>
					</view>
				</view>
				
			</scroll-view>
		</view>
	</view>
</template>

<script>
	import {topList} from '../../common/api.js'
	import pageHeader from '../../components/pageHeader/pageHeader.vue'
	export default {
		data() {
			return {
				title: "网易云音乐",
				isShow: false,
				topList:[]
			}
		},
		onLoad() {
			topList().then(res=>{
				// console.log("榜单",res)
				this.topList = res
				
				// console.log("this.topList", this.topList)
			})
		},
		
		components:{
			pageHeader
		},
		methods: {
			toList(id){
				uni.navigateTo({
					url: '/pages/list/index?listId=' + id ,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style scoped>
	.index-search{
		display: flex;
		align-items: center;
		height: 80rpx;
		margin: 70rpx 30rpx 30rpx 30rpx;
		background-color: #f7f7f7;
		border-radius: 50rpx;
	}
	.index-search text{
		font-size: 26rpx;
		margin-left: 26rpx;
		margin-right: 26rpx;
	}
	.index-search input{
		font-size: 26rpx;
		flex: 1;
	}
	
	.index-list{
		margin: 0 30rpx;
		
	}
	.index-list-item{
		display: flex;
		margin-bottom: 34rpx;
	}
	.index-list-img{
		width: 212rpx;
		height: 212rpx;
		position: relative;
		border-radius: 20rpx;
		overflow: hidden;
		margin-right: 22rpx;
	}
	.index-list-img image{
		width: 212rpx;
		height: 212rpx;
	}
	.index-list-img text{
		font-size: 20rpx;
		position: absolute;
		 left: 12rpx;
		 bottom: 16rpx;
		 color: white;
	}
	
	.index-list-text{
		width: calc(100vw - 300rpx);
		font-size: 24rpx;
		line-height: 66rpx;
	}
	/* 不换行，超出部分用... 代替*/
	.index-list-text view{
		width: 100%;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;  
	}
</style>
